package config

import (
    "asset-management-go/global"
    "github.com/go-redis/redis"
    "log"
)

var RedisClient *redis.Client

func InitRedis() {
    RedisClient = redis.NewClient(&redis.Options{
        Addr:     Appconfig.Database.Redis.Host + ":" + Appconfig.Database.Redis.Port,
        DB:       Appconfig.Database.Redis.Db,
        Password: Appconfig.Database.Redis.Password,
    })

    _, err := RedisClient.Ping().Result()

    if err != nil {
        log.Fatalf("Redis连接异常：%v", err)
    }

    global.Redis = RedisClient
}
